﻿using UnityEngine;
public class HeroView : CombatantView
{
    void OnEnable()
    {
        ActionSystem.SubscribeReaction<HeroTurnStartGA>(HeroTurnStartPreReaction, ReactionTiming.PRE);
    }
    void OnDisable()
    {
        ActionSystem.UnsubscribeReaction<HeroTurnStartGA>(HeroTurnStartPreReaction, ReactionTiming.PRE);
    }
    public Hero hero;
    public void Setup(Hero herod)
    {
        hero = herod;
        MaxHealth = hero.Health;
        CurrentHealth = hero.CurrentHealth;
    }


    public override void Damage(int damageAmount)
    {
        // 先执行基类的逻辑
        base.Damage(damageAmount);

        // 再同步数据到 hero
        if (hero != null)
        {
            hero.CurrentHealth = CurrentHealth;
        }
    }
    public virtual void ClearDenfence()
    {
        defence = 0;
        healthTextBar.SetHealth(CurrentHealth, defence, MaxHealth);
    }
    public virtual void HeroTurnStartPreReaction(HeroTurnStartGA ga)
    {
        ClearDenfence();
    }
    //壁垒效果
    public void DisableClearDefence()
    {
        ActionSystem.UnsubscribeReaction<HeroTurnStartGA>(HeroTurnStartPreReaction, ReactionTiming.PRE);
    }
}